#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <queue>
#include <algorithm>
#include <cctype>
using namespace std;


{{CORE_CODE}}


// 辅助函数：去除字符串中的所有空格和方括号
string cleanInput(const string& s) {
    string res;
    for (char c : s) {
        if (!isspace(static_cast<unsigned char>(c)) && c != '[' && c != ']') {
            res += c;
        }
    }
    return res;
}

int main() {
    string line;
    getline(cin, line);
    vector<vector<int>> buildings;
    
    // 1. 彻底清洗输入：去除所有空格、[、]
    string cleaned = cleanInput(line);
    if (cleaned.empty()) {
        cout << "[]" << endl;
        return 0;
    }
    
    // 2. 按逗号分割所有数字（此时格式为 "0,2,3,2,5,3"）
    vector<int> allNums;
    stringstream ss(cleaned);
    string numStr;
    while (getline(ss, numStr, ',')) {
        if (numStr.empty()) continue;
        try {
            allNums.push_back(stoi(numStr));
        } catch (const invalid_argument& e) {
            cerr << "Invalid number format: " << numStr << endl;
            return 1;
        } catch (const out_of_range& e) {
            cerr << "Number out of range: " << numStr << endl;
            return 1;
        }
    }
    
    // 3. 每3个数字一组，组成建筑信息（left, right, height）
    for (size_t i = 0; i + 2 < allNums.size(); i += 3) {
        buildings.push_back({
            allNums[i],
            allNums[i + 1],
            allNums[i + 2]
        });
    }
    
    // 4. 计算天际线并输出
    vector<vector<int>> result = getSkyline(buildings);
    cout << "[";
    for (size_t i = 0; i < result.size(); ++i) {
        cout << "[" << result[i][0] << "," << result[i][1] << "]";
        if (i != result.size() - 1) {
            cout << ",";
        }
    }
    cout << "]" << endl;
    
    return 0;
}